home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 2 / CU Amiga Magazine's Super CD-ROM 02 (1996)(EMAP Images)(GB)[!][issue 1996-04].iso / magazine / amiga_e / elist.src.archive / 000007_crash!kirk.safb.af.mil!BWILLS_Thu, 10 Jun 93 14:08:21 PST.msg < prev    next >
Text File  |  1993-08-31  |  4KB  |  88 lines

  1. Received: by bkhouse.cts.com (V1.16/Amiga)
  2.     id AA00000; Thu, 10 Jun 93 14:08:21 PST
  3. Received: from kirk.safb.af.mil by crash.cts.com with smtp
  4.     (Smail3.1.28.1 #15) id m0o3sJq-0000ZfC; Thu, 10 Jun 93 12:29 PDT
  5. Message-Id: <m0o3sJq-0000ZfC@crash.cts.com>
  6. Date: 10 Jun 93 14:27:00 CST
  7. From: "Barry D. Wills" <BWILLS@kirk.safb.af.mil>
  8. To: "amigae" <amigae@bkhouse.cts.com>
  9. Subject: LIST2.E (re:  Son Le's questions about linked lists)
  10.  
  11. /* LIST2.E - In response to Son Le's linked list question. */
  12.  
  13. PROC main ()
  14.   DEF a [3] : STRING,
  15.       b [3] : STRING,
  16.       c [3] : STRING,
  17.       d [3] : STRING
  18.  
  19.   StrCopy (a, 'aaa', ALL)
  20.   StrCopy (b, 'bbb', ALL)
  21.   StrCopy (c, 'ccc', ALL)
  22.   StrCopy (d, 'ddd', ALL)
  23.  
  24.   WriteF ('d.next=\s\n', IF Next(d)=NIL THEN 'NIL' ELSE Next(d))
  25.  
  26.   /*------------*/
  27.   d:=Link(d,NIL)    /* At this point does nothing:  d.next is already NIL. */
  28.   /*------------*/
  29.  
  30.   /*------------*/
  31.   d:=Link(c,d)
  32.   /*------------*/
  33.  
  34.   /* c.next points to the string 'ddd'; d now points to the string 'ccc' */
  35.   /* because Link() returns the address of c.  Now the string 'ddd' can  */
  36.   /* only be accessed via Next(c).                                       */
  37.   WriteF ('a=\s b=\s c=\s d=\s c.next=\s\n', a, b, c, d, Next(c))
  38.  
  39.   /*------------*/
  40.   d:=Link(b,d)
  41.   /*------------*/
  42.  
  43.   /* b.next points to the string 'ccc' because d was reassigned the     */
  44.   /* address of 'ccc' in the previous Link() statement; d now points to */
  45.   /* the string 'bbb' because Link() returns the address of b.          */
  46.   WriteF ('b=\s b.next=\s d=\s\n', b, Next(b), d)
  47.  
  48.   /*------------*/
  49.   d:=Link(a,d)
  50.   /*------------*/
  51.  
  52.   /* a.next points to the string 'bbb' because d was reassigned the     */
  53.   /* address of 'bbb' in the previous Link() statement; d now points to */
  54.   /* the string 'aaa' because Link() returns the address of a.          */
  55.   WriteF ('a=\s a.next=\s d=\s\n', a, Next(a), d)
  56.  
  57.   /* Finally, everything that can be gotten from the linked strings:  */
  58.   WriteF ('a=\s  -> \s\n', a, Next(a))
  59.   WriteF ('b=\s  -> \s\n', b, Next(b))
  60.   WriteF ('c=\s  -> \s\n', c, Next(c))
  61.   WriteF ('d=\s  -> \s\n', d, Next(d))
  62.  
  63.   /***************************************************************************/
  64.   /* The final output of the program is:                                     */
  65.   /*                                                                         */
  66.   /* a=aaa  -> bbb                                                           */
  67.   /* b=bbb  -> ccc                                                           */
  68.   /* c=ccc  -> ddd                                                           */
  69.   /* d=aaa  -> aaa                                                           */
  70.   /*                                                                         */
  71.   /* Compare the values pointed to by the Next() links in this program and   */
  72.   /* list1.e.  This is the difference in what the code does, not to mention  */
  73.   /* the different routes used to get there.                                 */
  74.   /*                                                                         */
  75.   /* Hope this sheds *some* light!  It might help if you're familiar with    */
  76.   /* how the DrawBorder() graphics function works on border structures that  */
  77.   /* are linked together, and how the DrawText() intuition function works on */
  78.   /* intuitext structures that are linked together.  Also, the functions     */
  79.   /* MapList(), ForAll(), and Exists() only work on a single list variable,  */
  80.   /* NOT on linked lists.  I haven't found a good example for using these    */
  81.   /* yet.  Maybe later.  -- Barry                                            */
  82.   /***************************************************************************/
  83.  
  84.   CleanUp (0)
  85. ENDPROC
  86.  
  87.  
  88. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%